<!DOCTYPE html>
<html>
<head>
    <title>Selectors API Example</title>
</head>
<body>
    <div id="myDiv">
        <h1>HTML Ipsum Presents</h1>
                   
        <p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. <a href="#">Donec non enim</a> in turpis pulvinar facilisis. Ut felis.</p>
        
        <h2>Header Level 2</h2>
                   
        <ol>
           <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
           <li>Aliquam tincidunt mauris eu risus.</li>
        </ol>
        
        <blockquote><p>Lorem ipsum dolor sit amet, <strong>consectetur adipiscing elit</strong>. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.</p></blockquote>
        
        <h3>Header Level 3</h3>
        
        <ul>
           <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
           <li>Aliquam tincidunt mauris eu risus.</li>
        </ul>
    </div>
    <script type="text/javascript">
    
        if (document.querySelectorAll){
            
            //get all <em> elements in a <div> (similar to getElementsByTagName("em"))
            var ems = document.getElementById("myDiv").querySelectorAll("em");
            alert(ems.length);
                               
            //get all elements with class of "selected"
            var selecteds = document.querySelectorAll(".selected");
            alert(selecteds.length);
            
            //get all <strong> elements inside of <p> elements
            var strongs = document.querySelectorAll("p strong");
            alert(strongs.length);
        
        
        } else {
            alert("Selectors API not supported in this browser");
        }

    </script>
</body>
</html>